#include "heartbeathelp.h"

heartBeatHelp::heartBeatHelp()
{
    m_heart_timer = new QTimer(this);
    m_count = 0;
    connect(m_heart_timer, SIGNAL(timeout()), this, SLOT(slotTimeOut()));
}

void heartBeatHelp::startHeartTimer()
{
    m_heart_timer->start(2000);
}

void heartBeatHelp::slotTimeOut()
{
    if (m_count > 2)
    {
        m_count = 0;
        m_heart_timer->stop();

        emit sigHeartBad();
        return;
    }
    m_count++;
    emit sigHeartReq();
}

void heartBeatHelp::slotHeartBack()
{
    m_count = 0;
}
